package com.roin.learn.freemarker.controller;

import com.roin.learn.freemarker.entity.Book;
import com.roin.learn.freemarker.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * 公共标签库使用示例Controller
 */
@Controller
public class CommonTagController {
    @Autowired
    BookService bookService;
    @RequestMapping("common_tag.htm")
    public ModelAndView execute(){
        ModelAndView mav = new ModelAndView("freemarker/commonTag");
        List<Book> books = bookService.getAll();
        mav.addObject("books", books);
        return mav;
    }
}
